<?php
class Category extends AppModel {
	var $name = 'Category';
	var $validate = array(
		'name' => array(
			'rule' 			=> 'notEmpty',
			'message' 		=> 'Category Name is not empty.'
		),
		'level'	=> array(
			'rule'			=> 'numeric',
			'message'		=> 'Level is a number!'
		),
		'orders' => array(
			'rule'			=> 'numeric',
			'message'		=> 'Order is a number!'
		)
	);
	
	 var $belongsTo = array(
		'Parentcat' =>array(
			'className' => 'Category',
			'foreignKey' => 'parent_id'
		),
     );

 	var $hasMany = array(
	    'Childcat' =>array(
	    	'className' => 'Category',
	        'foreignKey' => 'parent_id'
	        ),
	    'Product' => array(
	        'className' => 'Product',
	        'foreignKey' => 'category_id'
	        )
    ); 
}
?>